import { HttpException, HttpStatus } from '@nestjs/common';
import { Request, Response, NextFunction } from 'express';

class CustomException extends HttpException {
  constructor(message: string, status: HttpStatus) {
    super({ message, status }, status);
  }
}

export function contentMiddleware(
  req: Request,
  res: Response,
  next: NextFunction,
) {
  req['customException'] = CustomException;

  next();
}
